home *** CD-ROM | disk | FTP | other *** search
- #include "includes.h"
- #include "defines.h"
- #include "funcs.h"
-
- void jookysock(dir, title)
- char *dir ;
- char *title ;
- {
- their_size=sizeof(struct sockaddr_in);
- if ((new_fd=accept(fd,&their_addr,&their_size))!=-1)
- {
- if (!fork()) /* this is the kid */
- {
-
- memset(argstart,0,pssize);
- sprintf((char *)argstart,"jookysockd [port %d] [%s] [%s]",port,dir,title);
- instring=calloc(1,256);
- if (usepasswd==1)
- {
- memset(guess,0,80);
- write(new_fd,"password: ",10);
- read (new_fd,guess,80);
- if (strncmp(guess,password,strlen(password))!=0)
- {
- close (new_fd);
- exit(0) ;
- }
- } else {
- write(new_fd,"welcome!\n",9);
- }
- read(new_fd,instring,10);
-
- if (strncmp(instring,"quer",4)==0)
- {
- stringy=calloc(1,256);
- sprintf(stringy,"\n\n\nmp3 directory : %s\n\nmp3 title : %s\n\n",dir,title);
- write(new_fd,stringy,strlen(stringy));
- free(stringy);
- }
-
- if (strncmp(instring,"next",4)==0)
- {
- kill(getppid(),NEXT);
- }
-
- if (strncmp(instring,"repe",4)==0)
- {
- kill(getppid(),PREV);
- }
-
- if (strncmp(instring,"prev",4)==0)
- {
- kill(getppid(),PREV);
- usleep(250000);
- kill(getppid(),PREV);
- }
-
- if (strncmp(instring,"paus",4)==0)
- {
- kill(getppid(),PAUSE);
- }
-
- if (strncmp(instring,"resu",4)==0)
- {
- kill(getppid(),RESUME);
- }
-
- if (strncmp(instring,"quit",4)==0)
- {
- kill(getppid(),QUIT);
- }
-
- if (strncmp(instring,"stop",4)==0)
- {
- kill(getppid(),QUIT);
- }
-
- if (strncmp(instring,"help",4)==0)
- {
- write (new_fd,"query: current dir and title\n",31);
- write (new_fd,"next: next title\n",19);
- write (new_fd,"prev: previous title\n",23);
- write (new_fd,"repeat: restart current title\n",30);
- write (new_fd,"pause: pause playback\n",23);
- write (new_fd,"resume: resume playback\n",24);
- write (new_fd,"quit: terminate playback\n",27);
- write (new_fd,"stop: terminate playback\n",27);
- }
- free(instring);
- close (new_fd);
- exit(0) ;
- } else
- {
- close(new_fd);
- while(waitpid(-1,NULL,WNOHANG) > 0); /* clean up brats */
- }
- }
- }
-